package Y2024.M11.D14;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 25228
 * Date: 2024-11-14
 * Time: 8:03
 */
public class Main {
    public static void main(String[] args) {
        Person[] persons=new Person[]{new Person(10),new Person(12),new Person(9)};
        Arrays.sort(persons);
        System.out.println(Arrays.toString(persons));
    }
}

class Person implements Comparable<Person>{
    int age;
    Person(int age){
        this.age=age;
    }

    @Override
    public int compareTo(Person o) {
        return this.age - o.age;
    }

    @Override
    public String toString() {
        return "Person{" + "age=" + age + '}';
    }
}

